package com.hbnu.exercise.File;

import java.io.File;
import java.io.IOException;

public class Demo01
{
    public static void main(String[] args)
    {
        String path = "E:" + File.separator + "demo.txt";
        File file = new File(path);
        boolean flag;

        if (file.exists())
        {
            flag = file.delete();
            if (flag)
                System.out.println("删除成功");
            else
                System.out.println("删除失败");
        }
        else
        {
            try
            {
                flag = file.createNewFile();
                if (flag)
                    System.out.println("创建成功");
                else
                    System.out.println("创建失败");
            }
            catch (IOException e)
            {
                System.out.println("文件创建异常");
            }
        }
    }
}
